package Model.Draw.Entities;

import Model.Draw.Coordinate;
import Model.Draw.Entities.Impl.StateJoint;
import Model.Draw.IStateDraw;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;

/**
 * Projeto de TCC: Editor de Diagramas de comunicação BlueJ
 * @author Jose
 */
public class StartStateDraw implements IStateDraw {

    private StateJoint center;
    private boolean selected;
    private Ellipse2D circle;

    public Color getColor() {
        return selected ? Color.red : Color.black;
    }

    @Override
    public void draw(Graphics g) {
        circle = new Ellipse2D.Double(center.getX().getCoordinate() - 20, center.getY().getCoordinate() - 20, 20, 20);
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setColor(getColor());
        g2.setStroke(new BasicStroke(2));
        g2.draw(circle);
        g2.fill(circle);
    }

    @Override
    public boolean contains(int x, int y) {
        return circle != null ? circle.contains(x, y) : false;
    }

    @Override
    public void select() {
        selected = true;
    }

    @Override
    public void unselect() {
        selected = false;
    }

    @Override
    public void move(int newX, int newY) {
        center.setX(new Coordinate(newX));
        center.setY(new Coordinate(newY));
    }

    @Override
    public void rename(String newName) {
    }

    @Override
    public StateJoint findNearstJointOf(IStateDraw other) {
        return null;
    }

    @Override
    public String getDescription() {
        return "";
    }
}
